package com.lottery.ruok.lottrey.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lottery.ruok.lottrey.R;
import com.lottery.ruok.lottrey.bean.LongDragonItem;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by ASUS on 2017/10/12.
 */

public class LongDragonAdapter extends BaseAdapter {
    private Context mContext;
    private ArrayList<LongDragonItem> items;

    public LongDragonAdapter(Context context, ArrayList<LongDragonItem> items) {
        mContext = context;
        this.items = items;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view != null) {
            holder = (ViewHolder) view.getTag();
        } else {
            view = LayoutInflater.from(mContext).inflate(R.layout.prize_number_item2, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        }

        if(items != null && items.size() > 0 && i < items.size()){
            holder.descp.setText(items.get(i).getText());
        }

        return view;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    static class ViewHolder {
        @BindView(R.id.descp)
        TextView descp;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
